import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

public class ScheduleServiceImpl implements ScheduleService {
    private List<Schedule> list = new ArrayList<>();

    @Override
    public void addSchedule(Movie movie, Hall hall, LocalDateTime time, double price) {
        Schedule s = new Schedule(movie, hall, time, price);
        list.add(s);
        Logger.log("添加排片：" + movie.getTitle() + " " + time);
    }

    @Override
    public void removeSchedule(int id) {
        list.removeIf(s -> s.getScheduleId() == id);
        Logger.log("删除排片 id=" + id);
    }

    @Override
    public List<Schedule> listSchedules() {
        return list;
    }

    @Override
    public Schedule getById(int id) {
        for (Schedule s : list) {
            if (s.getScheduleId() == id) return s;
        }
        return null;
    }
}